﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSessionModule.h
//    @Author           :    gaoyi
//    @Date             :    24-8-6
//    @Email            :    445267987@qq.com
//    @Module           :    NFSessionModule
//
// -------------------------------------------------------------------------

#pragma once

#include "proto_access2zone.pb.h"
#include "NFComm/NFCore/NFPlatform.h"
#include "NFLogicCommon/NFMMODynamicModule.h"

class NFSessionModule final : public NFMMODynamicModule
{
public:
	explicit NFSessionModule(NFIPluginManager* p);

	~NFSessionModule() override;

public:
	int Awake() override;

	/**
	 * @brief 处理来自服务器的信息
	 * @param msgId
	 * @param packet
	 * @param param1
	 * @param param2
	 * @return
	 */
	int OnHandleServerMessage(uint32_t msgId, NFDataPackage& packet, uint64_t param1, uint64_t param2) override;

public:
	/**
	 * 处理RPC服务查询Uin请求
	 *
	 * @param request 查询Uin的请求对象
	 * @param respone 查询Uin的响应对象
	 * @param proxyId 代理ID
	 * @param clientId 客户端ID
	 * @return 处理结果的整数值
	 */
	int OnConnectionToken(proto_ff::Access2ZoneQueryUinReq& request, proto_ff::Access2ZoneQueryUinRes& respone, uint64_t proxyId, uint64_t clientId);

	/**
	 * 处理RPC服务启动请求
	 *
	 * @param request 启动请求对象
	 * @param respone 启动响应对象
	 * @param proxyId 代理ID
	 * @param clientId 客户端ID
	 * @return 处理结果的整数值
	 */
	int OnConnectionStart(proto_ff::Access2ZoneStart& request, proto_ff::Access2ZoneStartRes& respone, uint64_t proxyId, uint64_t clientId);

	/**
	 * 处理会话停止请求
	 *
	 * 当会话需要停止时，此函数被调用，通常用于清理或记录停止前的状态
	 *
	 * @param msgId
	 * @param packet 包含会话停止请求数据的包装对象
	 * @param param1
	 * @param param2
	 * @return 处理结果的整数值
	 */
	int OnConnectionStop(uint32_t msgId, NFDataPackage& packet, uint64_t param1, uint64_t param2);

	int OnConnectionMessage(uint32_t msgId, NFDataPackage& packet, uint64_t param1, uint64_t param2);

	int OnSetRouting(proto_ff::Access2ZoneSetRoutingRpcReq& request, proto_ff::Zone2AccessSetRoutingRpcRsp& respone, uint64_t proxyId, uint64_t clientId);

	static uint32_t BKDRHash(const void* key, int keyLen);
};
